package client;


import client.field.JSwarmArea;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.HeadlessException;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import model.PlayerColor;
import model.SwarmModel;

/**
 * Testfenster.java
 * Created: 05.05.2011, 14:02:33
 */

/**
 *
 * @author Jan-Philipp Kappmeier
 */
public class Testfenster extends JFrame {
	JSwarmArea upper;

	public Testfenster( String title ) throws HeadlessException {
		super( title );
		setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		setSize( 800, 600 );
		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
		setLocation( (d.width - getSize().width) / 2, (d.height - getSize().height) / 2 );

		setLayout( new BorderLayout() );

		
		upper = new JSwarmArea();
		upper.setSwarmModel(new SwarmModel());
		upper.startNewGame(PlayerColor.White, false);
		
		this.add( upper, BorderLayout.CENTER );
		
	}
	



	public static void main( String[] arguments ) {
		SwingUtilities.invokeLater( new Runnable() {
			@Override
			public void run() {
				// Change look and feel to native, if possible.
				try {
					UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
				} catch( ClassNotFoundException ex ) {
					JOptionPane.showMessageDialog( null, "Look and feel cannot be loaded.", "Error", JOptionPane.ERROR_MESSAGE );
				} catch( InstantiationException ex ) {
					JOptionPane.showMessageDialog( null, "Look and feel cannot be loaded.", "Error", JOptionPane.ERROR_MESSAGE );
				} catch( IllegalAccessException ex ) {
					JOptionPane.showMessageDialog( null, "Look and feel cannot be loaded.", "Error", JOptionPane.ERROR_MESSAGE );
				} catch( UnsupportedLookAndFeelException ex ) {
					JOptionPane.showMessageDialog( null, "Look and feel cannot be loaded.", "Error", JOptionPane.ERROR_MESSAGE );
				}
				Testfenster t = new Testfenster( "Testfenster fuer Hive-Spielfeld" );
				t.setVisible( true );
			}
		});
	}
}
